package com.ze.familydayverpm.adapter;

import java.util.List;

import com.ze.familyday.familyphotoframesquare.R;
import com.ze.model.TemplateModel;


import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class TemplateListViewAdapter extends BaseAdapter{

	private List<TemplateModel> mList;
	private Context mContext;
	private LayoutInflater mInflater;
	
	int layoutId;
	
	public TemplateListViewAdapter(List<TemplateModel> list, Context context) {
		// TODO Auto-generated constructor stub
		this.mList = list;
		this.mContext = context;
		this.mInflater = LayoutInflater.from(mContext);
		layoutId = R.layout.template_list_item;
	}
	
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return mList == null ? 0 : mList.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return mList.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		
		Holder holder;
		if (convertView == null) {
			convertView = mInflater.inflate(layoutId, null);
			holder = new Holder();
			holder.subjectTv = (TextView) convertView.findViewById(R.id.subjectTv);
			convertView.setTag(holder);
		}else {
			holder = (Holder)convertView.getTag();
		}
		holder.subjectTv.setText(mList.get(position).getSubject());
		return convertView;
	}
	
	class Holder{
		TextView subjectTv;
	}

}
